package com.sm.ticket.controller;


import com.sm.ticket.service.TicketService;
import com.sm.tool.entity.request.AddTicketsRequest;
import com.sm.tool.entity.request.PageInfo;
import com.sm.tool.entity.response.ReturnData;
import com.sm.tool.entity.vo.TicketsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/v1/oper")
@Api(tags = "优惠卷相关操作Api", value = "优惠卷相关操作Api",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class TicketController {

    @Autowired
    private TicketService ticketService;

    @ApiOperation(value = "管理员添加优惠券",notes = "管理员添加优惠券")
    @PostMapping("/admin/add_tickets")
    public ReturnData addTickets(
            @RequestHeader
            @ApiParam("管理员令牌") String adminToken,
            @Validated @RequestBody AddTicketsRequest addTicketsRequest
    ) {
        return ticketService.addTickets(adminToken,addTicketsRequest);
    }


    @ApiOperation(value = "查询优惠券列表",notes = "查询优惠券列表")
    @PostMapping("/admin/query_tickets")
    public ReturnData<List<TicketsVO>> queryTickets(
            @RequestHeader
            @ApiParam("管理员令牌") String adminToken,
            @RequestBody(required = false) PageInfo pageInfo
    ) {
        return ticketService.queryTickets(pageInfo);
    }
}
